import { Component, Injector } from '@angular/core';
import { AppComponentBase } from '@abp/components';
import {
  AliSmsCodeSettingEditDto,
  SmsCodeSettingServiceProxy,
  SmsCodeSettingEditDto,
} from '@abp/service-proxies/service-proxies';

@Component({
  templateUrl: './sms-code-settings.component.html',
  styleUrls: ['./sms-code-settings.component.less'],
})
export class SmsCodeSettingComponent extends AppComponentBase {
  aliSmsCode: AliSmsCodeSettingEditDto = new AliSmsCodeSettingEditDto();

  constructor(
    injector: Injector,
    private smsCodeService: SmsCodeSettingServiceProxy,
  ) {
    super(injector);
  }

  ngOnInit(): void {
    this.smsCodeService.getAllSettings().subscribe(setting => {
      this.aliSmsCode = setting.aliSmsCodeSetting;
    });
  }

  submitForm() {
    let smsCodeSettings = new SmsCodeSettingEditDto();
    smsCodeSettings.aliSmsCodeSetting = this.aliSmsCode;
    this.smsCodeService.updateAllSettings(smsCodeSettings).subscribe(result => {
      this.notify.success('保存成功！');
    });
  }
}
